package main

import (
	"fmt"
	"math/rand"
	"time"
)

func selectSort(nums *[]int) {
	if nums == nil || len(*nums) == 0 {
		return
	}

	var pos int
	for i := 0; i < len(*(nums)); i++ {
		pos = i
		for j := i + 1; j < len(*nums); j++ {
			if (*nums)[j] < (*nums)[pos] {
				pos = j
			}
		}

		if pos != i {
			temp := (*nums)[pos]
			(*nums)[pos] = (*nums)[i]
			(*nums)[i] = temp
		}
	}

}

func main() {
	nums := make([]int, 100000)

	startTime := time.Now()

	for i := 0; i < 1; i++ {
		for i := 0; i < len(nums); i++ {
			nums[i] = rand.Intn(10000000)
		}

		selectSort(&nums)
	}

	endTime := time.Now()

	//fmt.Println(nums)
	fmt.Println("time: ", endTime.Sub(startTime))
}
